﻿using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.XPath;

namespace FFACETools
{
    public partial class FFACE
    {
        /// <summary>
        /// This class will parse the resources.xml file to
        /// translate ID <-> Names of spells/abilities/items
        /// </summary>
        public class ParseResources
        {
            #region Constants

            /// <summary>
            /// Name of the resources.xml file
            /// </summary>
            private const string RESOURCES_FILE_NAME = "resources.xml";

            #endregion

            /// <summary>
            /// Will get the name of the passed area ID
            /// </summary>
            /// <param name="id">ID of the area to get the name for</param>
            public static string GetAreaName(int id)
            {
                string sResult = String.Empty;

                XPathDocument document = new XPathDocument(RESOURCES_FILE_NAME);

                XPathNavigator node = document.CreateNavigator().SelectSingleNode("//resources/areas/entry[@id='" + id + "']");

                if (null != node && !String.IsNullOrEmpty(node.Value))
                    sResult = node.Value;

                return sResult;

            } // @ public static string GetAreaName(int id)

            /// <summary>
            /// Will get the name of the passed item ID
            /// </summary>
            /// <param name="id">ID of the item to get the name for</param>
            public static string GetItemName(int id)
            {
                string sResult = String.Empty;

                XPathDocument document = document = new XPathDocument(RESOURCES_FILE_NAME);

                XPathNavigator node = document.CreateNavigator().SelectSingleNode("//resources/items/entry[@id='" + id + "']");

                if (null != node && !String.IsNullOrEmpty(node.Value))
                    sResult = node.Value;

                return sResult;

            } // @ public static string GetItemName(int id)

            /// <summary>
            /// Will get the name of the passed status effect
            /// </summary>
            /// <param name="id">ID of the area to get the name for</param>
            public static string GetStatusEffectName(StatusEffect statusEffect)
            {
                string sResult = String.Empty;

                XPathDocument document = new XPathDocument(RESOURCES_FILE_NAME);

                XPathNavigator node = document.CreateNavigator().SelectSingleNode("//resources/status/entry[@id='" + statusEffect + "']");

                if (null != node && !String.IsNullOrEmpty(node.Value))
                    sResult = node.Value;

                return sResult;

            } // @ public static string GetAreaName(int id)

        } // @ public class ParseResources
    } // @ public partial class FFACE
}
